<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
<div id="app">
    <h2>当前计数: {{count}}</h2>
    <!-- <button v-on:click="count++">+</button>
    <button v-on:click="count--">-</button> -->

    <!-- v-on 接收响应事件处理 -->
    <!-- 语法糖：简写，一般是某种语法太过复杂，给点甜头，使用简写 -->
    <!-- click指令：点击后触发事件 -->
    <button v-on:click="add">+</button>
    <button v-on:click="sub">-</button>
    
</div>

<!-- cdn引用 -->
<!-- 开发环境 -->
<!-- <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> -->
<!-- 生产环境 -->
<!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script> -->
<script src="../js/vue.js"></script>
<script>

    // proxy : 代理 Model
    const obj = {
        count : 0
    }

    const app = new Vue
    (
        {
            el : "#app",
            data : obj,
            methods : {                         // 该属性用于在Vue对象中定义方法
                add : function ()
                {
                    console.log("add被执行");
                    this.count++
                },
                sub : function ()
                {
                    console.log("sub被执行");
                    this.count--
                }
            },
            beforeCreate : function()
            {
              console.log("创建之前执行") ;
            },
            created : function ()
            {
                console.log("created");
            },
            mounted : function ()
            {
                console.log("mounted");
            }
        }
    )   
</script>


</body>
</html>